<?php

require_once 'models/DAL/ContatoDAO.php';

class Application_Model_DbTable_Contato extends Zend_Db_Table_Abstract {

    protected $_name = 'Contato';
    protected $_primary = 'idContato';
    protected $_dependentTables = array('Newsletter', 'Misc');
    protected $_referenceMap = array(
        "Usuario" => array(
            "columns" => array('codUsuario'),
            "refTableClass" => "Application_Model_DbTable_Usuario",
            "refColumns" => array("idUsuario"),
        )
    );

    public function addContatos(array $contatos) {
        $return = array();

        foreach ($contatos as $contato) {
            $return[] = $this->insert(array(
                'codUsuario' => $contato->getCodUsuario(),
                'email' => $contato->getEmail(),
                'telefone' => $contato->getTelefone(),
                'celular' => $contato->getCelular(),
                'descricaoProdServ' => $contato->getDescProdServ(),
                'carteiraClientes' => $contato->getCarteiraClientes() ? 1 : 0,
                'carroProprio' => $contato->getCodUsuario() ? 1 : 0
                    )
            );
        }
        (count($return)) ? $return = TRUE : $return = FALSE;

        return $return;
    }

}

